/*
 * @lc app=leetcode.cn id=1266 lang=typescript
 *
 * [1266] 访问所有点的最小时间
 */

// @lc code=start
function minTimeToVisitAllPoints(points: number[][]): number {
    let count = 0;
    for (let i = 1; i < points.length; i++) {
        const prev = points[i - 1];
        const element = points[i];
        // 数学算法
        const x = Math.abs(element[0] - prev[0]);
        const y = Math.abs(element[1] - prev[1]);
        count += Math.max(x, y);
    }
    return count;
}
// @lc code=end
